app.service('refundService', ['$http', '$q', 'utilService', '$cookies', function ($http, $q, utilService, $cookies) {
    //查询店铺下拉框
    this.getShopList = function ($scope) {
        var deferred = $q.defer();
        utilService.get({
            url: $scope.app.domain + 'shop/list'
        }).then(function (response) {
            deferred.resolve(response.data);
        }, function (e) {
            console.error(e);
            deferred.reject("连接服务器出错");
        });
        return deferred.promise;
    };

    this.update = function($scope){
        var deferred = $q.defer();
        utilService.api({
            url:$scope.app.domain + 'orders/refund/update',
            data:$scope.ordersRefundVO,
            method:'PUT'
        }).then(function(result){
            deferred.resolve(result);
        });
        return deferred.promise;
    };

    this.agree = function($scope){
        var deferred = $q.defer();
        utilService.api({
            url:$scope.app.domain + 'orders/refund/agree',
            data:{id:$scope.ordersRefundVO.id},
            method:'PUT'
        }).then(function(result){
            deferred.resolve(result);
        });
        return deferred.promise;
    };

    this.query = function ($scope) {
        var deferred = $q.defer();
        utilService.get({
            url: $scope.app.domain + 'goods/refund/find',
            params:{ordersGoodsId:$scope.goodsRefundVO.id}
        }).then(function (response) {
            deferred.resolve(response.data);
        }, function (e) {
            console.error(e);
            deferred.reject("连接服务器出错");
        });
        return deferred.promise;
    };
}]);